﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace HelloWPF.Animation
{
    public struct POINT
    {
        public int X;
        public int Y;
        public POINT(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //this.gridRoot.AddHanlder(Button.ClickEvent, new RoutedEventHandler(this.ButtonClicked))

            this.AddHandler(Button.ClickEvent, new RoutedEventHandler((obj, e) =>
            {
                var OriginalSource = (e.OriginalSource as FrameworkElement).Name;
                Debug.WriteLine("Window_Click");
            }), true);

            var window = Window.GetWindow(this.qiu);

            //// Return the general transform for the specified visual object.
            //GeneralTransform generalTransform1 = qiu.TransformToAncestor(this);
            //Point currentPoint2 = generalTransform1.Transform(new Point(0, 0));
            //Task task = new Task(() => this.DoSomethingLong());
            //task.Start();
        }

        private void DoSomethingLong()
        {
           //本来应该这里获取球的实时位置，进行暂停，而不是通过按钮点击。
           //while(true)
           // {
           //     Dispatcher.Invoke(() =>
           //     {
           //         var window = Window.GetWindow(this.qiu);

                   

           //         GeneralTransform generalTransform1 = qiu.TransformToAncestor(window);
           //         Point currentPoint = generalTransform1.Transform(new Point(0, 0));
           //     });
           //     //Vector vector = VisualTreeHelper.GetOffset(qiu);

           //     //// Convert the vector to a point value.
           //     //Point currentPoint = new Point(vector.X, vector.Y);
           //     Thread.Sleep(200);
           // }
        }
    }
}
